=begin pod

=TITLE class Stash

=SUBTITLE Table for "our"-scoped symbols

    class Stash is Hash { }

A C<Stash> is a hash that is used for symbol tables at the package scoping level
in Perl 6.

To get a Stash, you can call the C<.WHO> pseudo-method on a package (because it
answers the question I<who lives here?>), or if you write the package name as
a literal, append two colons:

    class Boring {
        class Nested { };
        our sub package_sub { }
        my sub lexical { };
        method a_method() { }
    }
    say Boring::.^name;             # OUTPUT: «Stash␤»
    say Boring.WHO === Boring::;    # OUTPUT: «True␤»

Since it inherits from L<Hash|/type/Hash>, you can use all the usual hash
functionality:

=for code :skip-test
say Boring::.keys.sort;         # OUTPUT: «(&package_sub Nested)␤»
say Boring::<Nested>;           # OUTPUT: «(Nested)␤»

As the example above shows only "our"-scoped things appear in the C<Stash>
(nested classes are "our" by default, but can be excluded with "my".)  Lexicals
and methods are not included in a Stash, since they do not live in the package
table.  Lexicals live in a separate lexical pad, which is only visible from
inside the scope.  Methods (in the case that the package is also a class) have
a separate method table, and are accessible through introspection on the
class itself, via C<.can> and C<.^methods>.

=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
